package cn.flying.cloud.message.web;

import javax.annotation.Resource;

import java.util.UUID;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.flying.cloud.base.common.utils.Ft;
import cn.flying.cloud.base.common.vo.Rt;
import cn.flying.cloud.message.core.service.MessageService;
import cn.flying.cloud.message.model.MessageRequest;

/**
 * 消息推送处理服务
 *
 * @author: admin
 * @date: 2025年07月14日 14:36
 * @version: 1.0
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    private MessageService messageService;

    /**
     * 推送邮件
     *
     * @param req
     * @return
     */
    @PostMapping(value = "/sendMail")
    public Rt<?> sendMail(@RequestBody MessageRequest req) {
        req.setTenantId(Ft.Local.TenantId());
        req.setRequestNo(UUID.randomUUID().toString().replaceAll("-", ""));
        if (Ft.String.isBlank(req.getServiceCode())) {
            req.setServiceCode("default");
        }
//        req.setTplId("");
//        req.setParam(Maps.newHashMap());
//        req.setFilePaths(Lists.newArrayList());

        messageService.sendSimpleMail(req);
        return Rt.success("发送成功！");
    }

}
